/* Copyright 2010 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS.
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package org.file5.domain;

import org.compass.annotations.SearchableProperty;

import com.google.appengine.api.datastore.Text;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.NotSaved;


 
public class EntityComment<E extends BaseEntity > extends BaseEntity {
 

	/**
	 * 
	 */
	private static final long serialVersionUID = -8299406106113779822L;
	
	
	public static String FIELD_NAME_ENTITY_KEY = "entityKey";
	private Key<E> entityKey;	
	@NotSaved 
	E entity;
	
	@SearchableProperty(converter = "textConverter", name = "comment")	
	private Text comment;
	
	private Key<EntityComment> parentCommentKey;
	@NotSaved 
	EntityComment<E> parentComment;
	
	private Key<Person> authorKey;
	@NotSaved
	private Person author;

	private boolean authorBlogNotified; //是否把本评论通知到作者的博客了
	
	private boolean replyClosed; //是否关闭回复，关闭后不允许其他人继续回复本评论
	private String fromBlogUrl; //该评论初始发布在的博客地址
	
	public EntityComment() {
	}
	public Key<E> getEntityKey() {
		return entityKey;
	}
	public void setEntityKey(Key<E> entityKey) {
		this.entityKey = entityKey;
	}
	public E getEntity() {
		return entity;
	}
	public void setEntity(E entity) {
		this.entity = entity;
	}

	public Key<EntityComment> getParentCommentKey() {
		return parentCommentKey;
	}
	public void setParentCommentKey(Key<EntityComment> key) {
		this.parentCommentKey = key;
	}
	public EntityComment<E> getParentComment() {
		return parentComment;
	}
	public void setParentComment(EntityComment<E> parentComment) {
		this.parentComment = parentComment;
	}

	public String getComment() {
		return (comment == null) ? "" : comment.getValue();
	}

	public void setComment(String comment) {
		this.comment = new Text((comment == null) ? "" : comment);
	}

	public Key<Person> getAuthorKey() {
		return authorKey;
	}

	public void setAuthorKey(Key<Person> authorKey) {
		this.authorKey = authorKey;
	}

	public Person getAuthor() {
		return author;
	}

	public void setAuthor(Person author) {
		this.author = author;
	}
	
	public boolean isAuthorBlogNotified() {
		return authorBlogNotified;
	}
	public void setAuthorBlogNotified(boolean authorBlogNotified) {
		this.authorBlogNotified = authorBlogNotified;
	}
	public boolean isReplyClosed() {
		return replyClosed;
	}
	public void setReplyClosed(boolean replyClosed) {
		this.replyClosed = replyClosed;
	}
	public String getFromBlogUrl() {
		return fromBlogUrl;
	}
	public void setFromBlogUrl(String fromBlogUrl) {
		this.fromBlogUrl = fromBlogUrl;
	}

}

